<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Picture;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class ImageController extends Controller
{
    public function getImage(Request $request)
    {
        $type = $request->input('type');
        $data = Picture::where(['type' => $type, 'status' => 'on'])->orderBy('sort', 'desc')->get();
        $list = [];
        foreach ($data as $items) {
            $list[] = ['url' => env('APP_URL') . '/uploads/' . $items->path];
        }
        return array_column($list, 'url');
    }
}
